package br.com.android.games.daedal;

import br.com.games.daedal.DaedalTeam;
import br.com.games.daedal.Vertex;
import br.com.games.daedal.ia.Ares;
import br.com.games.daedal.imp.DaedalBoard;
import br.com.games.hefesto.Game;
import br.com.games.hefesto.Move;

public class AndroPlayer extends Ares {
	private DaedalDotsActivity ui;
	
	public AndroPlayer(DaedalDotsActivity daedalDotsActivity, DaedalTeam team) {
		super(team, 2);
		this.ui = daedalDotsActivity;
	}
	
	/*
	 * (non-Javadoc)
	 * @see br.com.games.daedal.ia.Ares#giveUp()
	 */
	@Override
	public boolean giveUp() {
		return ui.isFinishing();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see br.com.games.hefesto.ai.Atena#getMove(br.com.games.hefesto.Game)
	 */
	@Override
	public Move<Vertex> getMove(Game<? extends DaedalBoard, Vertex> game) {
		Move<Vertex> result = null;
		ui.update.sendEmptyMessage(DaedalDotsActivity.REQUEST_PROGRESS_OFF);
		Vertex v = null;
		
		while ((null==v) && game.isRunning()){
		  v = ui.getBoard().getSelected();		  
		  if (v!=null)
		    result = new Move<Vertex>(v);		  
		}
		
		return result;
	}
}
